home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / contrib / pdcurs22 / include / curspriv.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-26  |  14.1 KB  |  395 lines

  1. /*
  2. ***************************************************************************
  3. * This file comprises part of PDCurses. PDCurses is Public Domain software.
  4. * You may use this code for whatever purposes you desire. This software
  5. * is provided AS IS with NO WARRANTY whatsoever.
  6. * Should this software be used in another application, an acknowledgement
  7. * that PDCurses code is used would be appreciated, but is not mandatory.
  8. *
  9. * Any changes which you make to this software which may improve or enhance
  10. * it, should be forwarded to the current maintainer for the benefit of 
  11. * other users.
  12. *
  13. * The only restriction placed on this code is that no distribution of
  14. * modified PDCurses code be made under the PDCurses name, by anyone
  15. * other than the current maintainer.
  16. * See the file maintain.er for details of the current maintainer.
  17. ***************************************************************************
  18. */
  19. /*
  20. $Id$
  21. */
  22. /*
  23. *
  24. *                          CURSPRIV.H
  25. *
  26. * Header file for definitions and declarations for the
  27. * PDCurses package. These definitions should not be generally
  28. * accessible to programmers, but are provided if the applications
  29. * programmer decides to make the decision in favor of speed on a
  30. * PC over portability.
  31. *
  32. * Revision History:
  33. * Frotz 1.5Beta 900714  Added many levels of compiler support.
  34. *                       Added mixed prototypes for all "internal" routines.
  35. *                       Removed all assembly language.  Added EGA/VGA
  36. *                       support.  Converted all #ifdef to #if in all
  37. *                       modules except CURSES.H and CURSPRIV.H.
  38. *                       Always include ASSERT.H.  Added support for an
  39. *                       external malloc(), calloc() and free().
  40. *                       Added support for FAST_VIDEO (direct-memory writes).
  41. *                       Added various memory model support (for FAST_VIDEO).
  42. *                       Added much of the December 1988 X/Open Curses
  43. *                       specification.
  44. * bl    1.3     881005  All modules lint-checked with MSC '-W3' and turbo'C'
  45. *                       '-w -w-pro' switches.
  46. * bl    1.2     881002  Support (by #ifdef UCMASM) for uppercase-only
  47. *                       assembly routine names. If UCMASM if defined,
  48. *                       all assembler names are #defined as upper case.
  49. *                       Not needed if you do "MASM /MX. Also missing
  50. *                       declaration of cursesscroll(). Fixes thanks to
  51. *                       N.D. Pentcheff
  52. * bl    1.1     880306  Add _chadd() for raw output routines.
  53. * bl    1.0     870515  Release.
  54. *
  55. */
  56.  
  57. #ifndef __CURSES_INTERNALS__
  58. #define __CURSES_INTERNALS__
  59.  
  60. /* Always include... */
  61. #include <assert.h>
  62.  
  63.  
  64.  
  65. /*----------------------------------------------------------------------
  66. *       MEMORY MODEL SUPPORT:
  67. *
  68. *       MODELS
  69. *               TINY            cs,ds,ss all in 1 segment (not enough memory!)
  70. *               SMALL           cs:1 segment,           ds:1 segment
  71. *               MEDIUM          cs:many segments        ds:1 segment
  72. *               COMPACT         cs:1 segment,           ds:many segments
  73. *               LARGE           cs:many segments        ds:many segments
  74. *               HUGE            cs:many segments        ds:segments > 64K
  75. */
  76. #ifdef  __TINY__
  77. #  define SMALL 1
  78. #endif
  79. #ifdef  __SMALL__
  80. #  define SMALL 1
  81. #endif
  82. #ifdef  __MEDIUM__
  83. #  define MEDIUM 1
  84. #endif
  85. #ifdef  __COMPACT__
  86. #  define COMPACT 1
  87. #endif
  88. #ifdef  __LARGE__
  89. #  define LARGE 1
  90. #endif
  91. #ifdef  __HUGE__
  92. #  define HUGE 1
  93. #endif
  94.  
  95.  
  96. /*----------------------------------------------------------------------
  97. *       OPERATING SYSTEM SUPPORT:
  98. *
  99. *               DOS             The one we all know and love:-}
  100. *               OS/2            The new kid on the block.
  101. *               FLEXOS          A Real-time, protected-mode OS from
  102. *                               Digital Research, Inc.
  103. *                (AKA, the 4680 from IBM...)
  104. */
  105.  
  106. /*----------------------------------------*/
  107. #ifdef  DOS
  108. #  define FAST_VIDEO 1          /* We can write directly to the screen. */
  109. #  ifdef NDP
  110.      typedef union REGS16 Regs;
  111. #  else
  112.      typedef union REGS Regs;
  113. #  endif
  114.    extern Regs regs;
  115. #  ifdef GO32                           /* Note: works only in plain DOS... */
  116. #    define _FAR_POINTER(s,o)        (0xe0000000 + (((int)(s))<<4) + ((int)(o)))
  117. #    define _FP_SEGMENT(p)        (unsigned short)((((long)fp) >> 4) & 0xffff)
  118. #    define _FP_OFFSET(p)        ((unsigned short)fp & 0x000f)
  119. #  else
  120. #    ifdef __TURBOC__
  121. #      define _FAR_POINTER(s,o)    MK_FP(s,o)
  122. #    else
  123. #      if defined(NDP) || defined(WATCOMC)
  124. #        define _FAR_POINTER(s,o)    ((((int)(s))<<4) + ((int)(o)))
  125. #      else
  126. #        define _FAR_POINTER(s,o)    (((long)s << 16) | (long)o)
  127. #      endif
  128. #    endif
  129. #    define _FP_SEGMENT(p)        (unsigned short)(((long)fp) >> 4)
  130. #    define _FP_OFFSET(p)        ((unsigned short)fp & 0x000f)
  131. #  endif
  132.  
  133. #  ifdef GO32
  134.      unsigned char getdosmembyte (int offs);    /* see: private\_dosmem.c */
  135.      unsigned short getdosmemword (int offs);
  136.      void setdosmembyte (int offs, unsigned char b);
  137.      void setdosmemword (int offs, unsigned short w);
  138. #  else
  139. #    if SMALL || MEDIUM || MSC
  140. #      define getdosmembyte(offs)    (*((unsigned char far *) _FAR_POINTER(0,offs)))
  141. #      define getdosmemword(offs)    (*((unsigned short far *) _FAR_POINTER(0,offs)))
  142. #      define setdosmembyte(offs,x)  (*((unsigned char far *) _FAR_POINTER(0,offs)) = (x))
  143. #      define setdosmemword(offs,x)  (*((unsigned short far *) _FAR_POINTER(0,offs)) = (x))
  144. #    else
  145. #      define getdosmembyte(offs)    (*((unsigned char *) _FAR_POINTER(0,offs)))
  146. #      define getdosmemword(offs)    (*((unsigned short *) _FAR_POINTER(0,offs)))
  147. #      define setdosmembyte(offs,x)  (*((unsigned char *) _FAR_POINTER(0,offs)) = (x))
  148. #      define setdosmemword(offs,x)  (*((unsigned short *) _FAR_POINTER(0,offs)) = (x))
  149. #    endif
  150. #  endif
  151. #endif
  152.  
  153. /*----------------------------------------*/
  154. #ifdef  FLEXOS
  155. #  define FAST_VIDEO 1          /* We can use scopy()   */
  156. #  define GMODE  0 /* KLUDGE ALERT!
  157.                    * GMODE == 0 defines character mode structures in FLEXTAB.H.
  158.                    * GMODE == 1 defines graphics  mode structures in FLEXTAB.H.
  159.                    */
  160. #include <flextab.h>
  161. extern VIRCON vir;
  162. #endif
  163.  
  164.  
  165.  
  166.  
  167. /*----------------------------------------------------------------------
  168. *       MALLOC DEBUGGING SUPPORT:
  169. *
  170. *       Set EMALLOC and EMALLOC_MAGIC in order to use your private
  171. *       versions of malloc(), calloc(), and free().  This can help,
  172. *       but not solve, your malloc problems when debugging...
  173. *
  174. */
  175. #ifndef    INTERNAL
  176. #  define EMALLOC 0             /* Disable External Malloc            */
  177. #else
  178. #  define EMALLOC 0             /* Enable/Disable External Malloc       */
  179. #  define EMALLOC_MAGIC  0x0C0C /* Our magic indicator that we should   */
  180.                                 /* use our external malloc rather than  */
  181.                                 /* the runtime's malloc.                */
  182. #endif
  183.  
  184.  
  185. /*----------------------------------------------------------------------*/
  186. /* window properties */
  187. #define _SUBWIN         0x01    /* window is a subwindow            */
  188. #define _ENDLINE        0x02    /* last winline is last screen line */
  189. #define _FULLWIN        0x04    /* window fills screen              */
  190. #define _SCROLLWIN      0x08    /* window lwr rgt is screen lwr rgt */
  191. #define _PAD            0x10    /* X/Open Pad.                      */
  192. #define _SUBPAD         0x20    /* X/Open subpad.                   */
  193.  
  194.  
  195.  
  196.  
  197. /*----------------------------------------------------------------------*/
  198. /* Miscellaneous */
  199. #define _INBUFSIZ       512     /* size of terminal input buffer */
  200. #define _NO_CHANGE      -1      /* flags line edge unchanged     */
  201.  
  202.  
  203.  
  204.  
  205. /* @@@ THESE SHOULD BE INDIVIDUAL FUNCTIONS, NOT MACROS! */
  206. #define _BCHAR          0x03    /* Break char        (^C)         */
  207. #define _ECHAR          0x08    /* Erase char        (^H)         */
  208. #define _DWCHAR         0x17    /* Delete Word char (^W)         */
  209. #define _DLCHAR         0x15    /* Delete Line char (^U)         */
  210. #define _GOCHAR         0x11    /* ^Q character                  */
  211. #define _PRINTCHAR      0x10    /* ^P character                  */
  212. #define _STOPCHAR       0x13    /* ^S character                  */
  213. #define  NUNGETCH       20      /* max # chars to ungetch()      */
  214.  
  215.  
  216.  
  217.  
  218. /* Setmode stuff */
  219. struct cttyset
  220. {
  221.     bool    been_set;
  222.     SCREEN    saved;
  223. };
  224.  
  225. extern struct cttyset c_sh_tty;         /* tty modes for shell_mode */
  226. extern struct cttyset c_pr_tty;         /* tty modes for prog_mode  */
  227. extern struct cttyset c_save_tty;
  228. extern struct cttyset c_save_trm;
  229.  
  230. /* Printscan stuff */
  231. extern char c_printscanbuf[];           /* buffer used during I/O */
  232.  
  233. /* tracing flag */
  234. extern bool trace_on;
  235.  
  236. /* Strget stuff */
  237. extern char*    c_strbeg;
  238.  
  239. /* doupdate stuff */
  240. extern WINDOW*  twin;                   /* used by many routines */
  241.  
  242. /* Monitor (terminal) type information */
  243. #define _NONE           0x00
  244. #define _MDA            0x01
  245. #define _CGA            0x02
  246. #define _EGACOLOR       0x04
  247. #define _EGAMONO        0x05
  248. #define _VGACOLOR       0x07
  249. #define _VGAMONO        0x08
  250. #define _MCGACOLOR      0x0a
  251. #define _MCGAMONO       0x0b
  252. #define _FLEXOS         0x20            /* A Flexos console */
  253. #define _MDS_GENIUS     0x30
  254. #define _UNIX_COLOR     0x40
  255. #define _UNIX_MONO      0x41
  256.  
  257. /* Text-mode font size information */
  258. #define _FONT8  8
  259. #define _FONT14 14
  260. #define _FONT15 15              /* GENIUS */
  261. #define _FONT16 16
  262.  
  263.  
  264. /*----------------------------------------------------------------------
  265. *       ANSI C prototypes.  Be sure that your compiler conditional
  266. *       compilation definitions above define ANSI to be non-zero
  267. *       if you compiler supports prototypes.
  268. */
  269. #ifdef     ANSI
  270. #  ifdef  CPLUSPLUS
  271.      extern "C" {
  272. #  endif
  273. int             PDC_backchar( WINDOW*, char*, int* );
  274. bool            PDC_breakout( void );
  275. int             PDC_chadd( WINDOW*, chtype, bool, bool );
  276. bool            PDC_check_bios_key( void );
  277. int             PDC_chg_attr( WINDOW*, chtype, int, int, int, int );
  278. int             PDC_chins( WINDOW*, chtype, bool );
  279. int             PDC_clr_scrn( WINDOW* );
  280. int             PDC_clr_update( WINDOW* );
  281. int             PDC_copy_win( WINDOW *,WINDOW *,int,int,int,int,int,int,int,int,bool );
  282. int             PDC_cursor_off( void );
  283. int             PDC_cursor_on( void );
  284. int             PDC_fix_cursor( int );
  285. int             PDC_gattr( void );
  286. int             PDC_get_bios_key( void );
  287. int             PDC_get_columns( void );
  288. bool            PDC_get_ctrl_break( void );
  289. int             PDC_get_cur_col( void );
  290. int             PDC_get_cur_row( void );
  291. int             PDC_get_cursor_pos( int*, int* );
  292. int             PDC_get_cursor_mode( void );
  293. int             PDC_get_font( void );
  294. int             PDC_get_rows( void );
  295. int             PDC_gotoxy( int, int );
  296. int             PDC_init_atrtab(void);
  297. WINDOW*         PDC_makenew( int, int, int, int );
  298. int             PDC_newline( WINDOW*, int );
  299. int             PDC_print( int, int, int );
  300. int             PDC_putc( chtype, chtype );
  301. int             PDC_putchar( chtype );
  302. int             PDC_putctty( chtype, chtype );
  303. int             PDC_rawgetch( void );
  304. int             PDC_sanity_check( int );
  305. int             PDC_scr_close( void );
  306. int             PDC_scr_open( SCREEN*, bool );
  307. int             PDC_scroll( int, int, int, int, int, chtype );
  308. int             PDC_set_80x25( void );
  309. int             PDC_set_ctrl_break( bool );
  310. int             PDC_set_cursor_mode( int, int );
  311. int             PDC_set_font( int );
  312. int             PDC_set_rows( int );
  313. int             PDC_split_plane( WINDOW*, char*, char*, int, int, int, int );
  314. int             PDC_sysgetch( void );
  315. bool            PDC_transform_line( int );
  316. void            PDC_usleep( long );
  317. int             PDC_validchar( int );
  318.  
  319. #if defined( OS2 ) && !defined( EMXVIDEO )
  320. VIOCONFIGINFO   PDC_query_adapter_type( void );
  321. VIOMODEINFO     PDC_get_scrn_mode( void );
  322. int             PDC_set_scrn_mode( VIOMODEINFO );
  323. bool            PDC_scrn_modes_equal (VIOMODEINFO, VIOMODEINFO);
  324. #else
  325. int             PDC_query_adapter_type( void );
  326. int             PDC_get_scrn_mode( void );
  327. int             PDC_set_scrn_mode( int );
  328. bool            PDC_scrn_modes_equal (int, int);
  329. #endif
  330.  
  331. #ifdef  FLEXOS
  332. int             PDC_flexos_8bitmode( void );
  333. int             PDC_flexos_16bitmode( void );
  334. char*           PDC_flexos_gname( void );
  335. #endif
  336.  
  337. #ifdef UNIX
  338. int             PDC_kbhit(void);
  339. int             PDC_setup_keys(void);
  340. #endif
  341.  
  342. #if defined (XCURSES)
  343. int            XCurses_redraw_curscr(void);
  344. int            XCurses_display_cursor(int,int ,chtype ,int ,int ,chtype );
  345. int            XCurses_rawgetch(void);
  346. bool           XCurses_kbhit(void);
  347. int            XCurses_instruct(int);
  348. int            XCurses_transform_line(long *, int , int , int );
  349. int            Xinitscr(void);
  350. int            Xendwin(void);
  351. #endif
  352.  
  353. #ifdef PDCDEBUG
  354. void            PDC_debug( char*,... );
  355. #endif
  356.  
  357. #ifdef  REGISTERWINDOWS
  358. bool            PDC_inswin( WINDOW*, WINDOW* );
  359. int             PDC_addtail( WINDOW* );
  360. int             PDC_addwin( WINDOW*, WINDOW* );
  361. int             PDC_rmwin( WINDOW* );
  362. WINDS*          PDC_findwin( WINDOW* );
  363. #endif
  364. #  ifdef  CPLUSPLUS
  365.      }
  366. #  endif
  367. #endif
  368.  
  369. #if defined(CHTYPE_LONG)
  370. #  define PDC_COLOR_PAIRS  64
  371. #  define PDC_OFFSET       32
  372. #  define MAX_ATRTAB      ((PDC_COLOR_PAIRS+1)*PDC_OFFSET)
  373. /* internal macros for attributes */
  374. #  define chtype_attr(ch)  (atrtab[((ch >> 19) & 0xFFFF)] << 8)
  375. #else
  376. #  define PDC_OFFSET        8
  377. #  define MAX_ATRTAB      272
  378. /* internal macros for attributes */
  379. #  define chtype_attr(ch)  ((atrtab[((ch >> 8) & 0xFF)] << 8) & A_ATTRIBUTES)
  380. #endif
  381.  
  382. #if defined(XCURSES)
  383. #define CURSES_EXIT     999999
  384. #define CURSES_REFRESH  999998
  385. #define CURSES_CHILD    999997
  386. #define CURSES_CURSOR   999996
  387. #define CURSES_CONTINUE 999995
  388. #define CURSES_BELL     999994
  389. #define CURSES_FLASH    999993
  390. #define CURSES_CLEAR    999992
  391. #endif
  392.  
  393. #endif /* __CURSES_INTERNALS__*/
  394.